package graph.drawingshapes
{
	import flash.display.Graphics;
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;
	
	import mx.events.PropertyChangeEvent;

	public class Outline extends EventDispatcher
	{
		public static const DefaultLineColor:uint = 0x000000;
		[Bindable]
		private var _lineColor:uint = DefaultLineColor;
		[Bindable]
		public function get lineColor():uint
		{
			return this._lineColor;
		}
		public function set lineColor(value:uint):void
		{
			if (value != this._lineColor)
			{
				var event:PropertyChangeEvent = PropertyChangeEvent.createUpdateEvent(this, "lineColor", this.lineColor, value);
				dispatchEvent(event);
				this._lineColor = value;
				dispatchEvent(new RedrawEvent());
			}
		}
		
		public static const DefaultLineWidth:Number = 1.0;
		[Bindable]
		private var _lineWidth:Number = DefaultLineWidth;
		[Bindable]
		public function get lineWidth():Number
		{
			return this._lineWidth;
		}
		public function set lineWidth(value:Number):void
		{
			if (value != this._lineWidth)
			{
				var event:PropertyChangeEvent = PropertyChangeEvent.createUpdateEvent(this, "lineWidth", this.lineWidth, value);
				dispatchEvent(event);
				this._lineWidth = value;				
				dispatchEvent(new RedrawEvent());
			}
		}
		
		public static const DefaultLineAlpha:Number = 1.0;
		[Bindable]
		private var _lineAlpha:Number = DefaultLineAlpha;
		[Bindable]
		public function get lineAlpha():Number
		{
			return this._lineAlpha;
		}
		public function set lineAlpha(value:Number):void
		{
			if (value != this._lineAlpha)
			{
				var event:PropertyChangeEvent = PropertyChangeEvent.createUpdateEvent(this, "lineAlpha", this.lineAlpha, value);
				dispatchEvent(event);
				this._lineAlpha = value;
				dispatchEvent(new RedrawEvent());
			}
		}
		
		public function Outline(lineColor:uint=DefaultLineColor, lineWidth:Number=DefaultLineWidth, lineAlpha:Number=DefaultLineAlpha, target:IEventDispatcher=null)
		{
			super(target);
			this.lineColor = lineColor;
			this.lineWidth = lineWidth;
			this.lineAlpha = lineAlpha;
		}
		
		public virtual function beginDrawing(graphics:Graphics):Graphics
		{
			graphics.lineStyle(this.lineWidth, this.lineColor, this.lineAlpha, true);
			return graphics;
		}
	}
}